home *** CD-ROM | disk | FTP | other *** search
/ Trading on the Edge / Trading On The Edge - CD-ROM Toolkit (Wayzata Technology)(2031)(1994).bin / pc / mac_file / vendor_d / neuralwa / nw2v50 / lvq.ind < prev    next >
File List  |  1993-08-23  |  5KB  |  278 lines

  1. inst4.1
  2. !*********************************************************************
  3. !*                                         *
  4. !*    Linear Vector Quantization (LVQ) Network Builder             *
  5. !*                                         *
  6. !*********************************************************************
  7. !
  8.  
  9. !    *** check that input / output PE count is non-zero
  10.  
  11. ?&In    1
  12. >bge    InOK
  13. @Err    "LVQ MUST have at least 1 input PE"
  14. :InOK
  15. ?&Out    2
  16. >bge    OutOK
  17. @Err    "LVQ MUST have at least 2 output categories"
  18. :OutOK
  19. ?&Prt    &Out
  20. >bge    Hid1OK
  21. =&Prt    &Out
  22. :Hid1OK
  23. ! Round up # protoypes for equidistribution
  24. ! Store #prototypes per class in n7
  25. =n7    &Prt
  26. +n7    &Out
  27. -n7    1
  28. /n7    &Out
  29. =&Prt    n7
  30. *&Prt    &Out
  31.  
  32. @LdCS    "lvq"            !control strategy
  33.  
  34. ! Build the LR schedule
  35. ! Use 3 cols for LVQ1, 2 for LVQ2
  36. @NLRS    "lvq"
  37.  
  38. ! First set up schedule transition points
  39. ! LVQ1
  40. ?Q1LC    10
  41. >bgt    Q1LCOK
  42. =Q1LC    10        !Force some LVQ1
  43. :Q1LCOK
  44. =n0    Q1LC        !Total # iterations for LVQ1
  45. /n0    3        !Transition count
  46.  
  47. =lcta    n0
  48. =lctb    n0
  49. *lctb    2
  50. =lctc    Q1LC
  51.  
  52. ! LVQ2
  53. =n0    Q2LC        !Total # iterations for LVQ2
  54. ?n0    0
  55. >ble    NoLVQ2
  56. /n0    2        !Transition count
  57. =lctd    lctc
  58. +lctd    n0
  59. =lcte    lctc
  60. +lcte    Q2LC
  61. =LrnN    lcte        !Total learn count
  62. >br    LRSParms
  63. :NoLVQ2
  64. =lctd    0
  65. =lcte    0
  66. =LrnN    lctc        !Total learn count
  67.  
  68. :LRSParms
  69. ! Parameter names
  70. =ArrX    1
  71. =lcft    "Attraction Rt1"
  72. =ArrX    2
  73. =lcft    "Attraction Rt2"
  74. =ArrX    3
  75. =lcft    "Repulsion Rate"
  76. =ArrX    4
  77. =lcft    "Conscience"
  78. =ArrX    5
  79. =lcft    "Frequency Est."
  80. =rcft    "Parzen Spread"
  81. =ArrX    6
  82. =lcft    "LVQ2 Width"
  83.  
  84. ! Attraction Rate 1
  85. =ArrX    1
  86. =lcfa    Q1LR
  87. =lcfb    lcfa
  88. /lcfb    2
  89. =lcfc    lcfb
  90. /lcfc    2
  91.  
  92. =lcfd    Q2LR
  93. =lcfe    lcfd
  94. /lcfe    2
  95.  
  96. ! Attraction Rate 2 (unused for LVQ2)
  97. =ArrX    2
  98. =lcfa    0.0
  99. =lcfb    0.0
  100. =lcfc    0.0
  101. =lcfd    0.0
  102. =lcfe    0.0
  103. ?Q1IC    0        ! In-class winner learns?
  104. >beq    RepulRt        ! If no, then don't set
  105. =lcfa    Q1LR
  106. =lcfb    lcfa
  107. /lcfb    2
  108. =lcfc    lcfb
  109. /lcfc    2
  110.  
  111. :RepulRt
  112. ! Repulsion Rate (unused for LVQ2)
  113. =ArrX    3
  114. =lcfa    Q1LR
  115. =lcfb    lcfa
  116. /lcfb    2
  117. =lcfc    lcfb
  118. /lcfc    2
  119.  
  120. =lcfd    0.0
  121. =lcfe    0.0
  122.  
  123. ! Conscience
  124. =ArrX    4
  125. =lcfa    Q1CF
  126. =lcfb    lcfa
  127. /lcfb    2
  128. =lcfc    lcfb
  129. /lcfc    2
  130.  
  131. =lcfd    0.0
  132. =lcfe    0.0
  133.  
  134. ! Frequency Estimation (unused for LVQ2)
  135. =ArrX    5
  136. =lcfa    Q1FE
  137. =lcfb    lcfa
  138. /lcfb    2
  139. =lcfc    lcfb
  140. /lcfc    2
  141.  
  142. =lcfd    0.0
  143. =lcfe    0.0
  144.  
  145. =rcfa    0.0        !Parzen WIndow
  146.  
  147. ! Width Parameter (LVQ2 only)
  148. =ArrX    6
  149. =lcfa    0.0
  150. =lcfb    0.0
  151. =lcfc    0.0
  152.  
  153. =lcfd    Q2WP
  154. =lcfe    lcfd
  155. *lcfe    2
  156. @SLRS
  157. =ArrX    0
  158.  
  159. =netn   "untitled"
  160. =DLnF    0            !learn  re-display off
  161. =DRcF    0            !recall re-display off
  162.  
  163. !    *** Build the Input Layer ***
  164.  
  165. @LLdf                !load default layer to mi_layer structure
  166. =LDln    "In"            !layer name
  167. =Lpes    &In            !copy # of input PEs from menu
  168. =x    100            !place to put layer on screen
  169. =y     80
  170. =n3    5            !PE Spacing
  171. *n3    n7
  172. *n3    &Out
  173. /n3    &In
  174. ?n3     1
  175. >bge    n3OK
  176. =n3     1
  177. :n3OK
  178. =LDsp    n3
  179. #Incl    "stdnwgtf.iif"        !standard # weight fields
  180. @LAdd                !add the input layer
  181.  
  182. !    *** Build the Kohonen Layer ***
  183.  
  184. @LLdf                !start with default layer again
  185. =LDln    "Kohonen"        !Kohonen layer
  186. =Lsum    "lvq"            !Summation Function
  187. =Lcmp    "lvq"            !Output Function
  188. =Llrn    "lvq"            !Learn Function
  189. =Lpes    &Prt            !Number of PE's
  190. =LInL    -1.0            !Should be same as input low value
  191. =LInH    1.0            !Should be same as input high value
  192. +y    100            !up higher on display
  193. =LDsp    5            !PE Spacing
  194. @LDfW                !Default # weight fields
  195. @LAdd
  196.  
  197. !    *** Connect Input Layer to the Kohonen layer ***
  198.  
  199. =SPEl    1            !Destination = Kohonen Layer
  200. @SlPE
  201. @NrPE
  202. =cnwt    0.0            !connection weight = 0.0
  203. =cnty    WVar            !fixed
  204. =cnsc    WRel            !Relative
  205. =NPEl    0            !Source = Input Layer
  206. @NrPE
  207. @LCFl                !fully connect to input layer
  208.  
  209. !    *** Build the output layer  ***
  210.  
  211. =x    100
  212. @LLdf                !load default layer to mi_layer structure
  213. =LDln    "Out"            !layer name
  214. =Lpes    &Out            !copy # of input PEs from menu
  215. =Lsum    "sum"            !Standard Summation Function
  216. =Ltrn    "linear"        !Transfer Function
  217. =Lcmp    "direct"        !Output Function
  218. +y    100            !up higher on display
  219. =LDsp    5            !PE Spacing
  220. *LDsp    n7
  221. #Incl    "stdnwgtf.iif"        !standard # weight fields
  222. @LAdd                !add the output layer
  223.  
  224. !    *** Connect Kohonen Layer to Output Layer ***
  225.  
  226. =cnwt    1.0            !connection weight = 1.0
  227. =cnty    WFix            !fixed
  228. =SPEl    2            !Destination = Output Layer
  229. =SPEn    0            !Output Layer PE index
  230. =NPEl    1            !Source = Kohonen Layer
  231. =NPEn    0            !Kohonen Layer PE index
  232. :L1 
  233. =n1    0            !n7 count
  234. :L2 
  235. @SlPE                !select next PE in output layer
  236. @NrPE                !select next PE in Kohonen layer
  237. @PCon                !Connect Kohonen PE  to output PE
  238. +n1    1            !increment n7 count
  239. +NPEn    1            !increment Kohonen Layer PE index    
  240. ?n1    n7            !check for loop end
  241. >blt    L2 
  242. +SPEn    1            !increment output Layer PE count
  243. ?SPEn    &Out
  244. >blt    L1 
  245.  
  246.  
  247. !    *** Select Control Strategy & L/R Schedule ***
  248.  
  249. @LLsl                !load super layer
  250. =LDnd    3            !Force network display
  251. =Lctl    "lvq"            !control strategy
  252. =Llrs    "lvq"            !L/R Schedule
  253. #Incl    "stdioset.iif"        !standard I/O settings
  254. =Lscl     -1.0             !input  low-value
  255. =Loff     1.0            !input  high-value
  256. =Llow     0.            !output low-value
  257. =Lhgh     1.            !output high-value
  258. =Lax1    Epch            !epoch size
  259. =Lax2    0            !Aux 2 used for optimized learning
  260. @SVsl                !save the super layer back
  261. !
  262. =Grph     1
  263. =GrLF    "lvq"            !instrument list file
  264. !
  265. ! Recall/Test modes
  266. =RnTm    1
  267. =RnRm    1
  268. !set to learn until
  269. =RnLm    4
  270. !
  271. =jogl    -1.0            !lower limit for jog
  272. =jogh    +1.0            !upper limit for jog
  273. =seed    257            !starting seed number
  274. @seed                !set the seed
  275. @Nini                !Initialize the network
  276. @EOF
  277.  
  278.